package tool.codescan.visitors;

import tool.codescan.loggers.VariableAndParameterLogger;
import japa.parser.ast.body.ClassOrInterfaceDeclaration;
import japa.parser.ast.visitor.VoidVisitorAdapter;

	/**
	 * @author jwb09119
	 * @date 2013/11/22
	 * 
	 * This visitor visits the *inside* of a java abstract class after the type information has been
	 * extracted from any file header.  As such is it concerned with static variables.
	 * It delegates methods, abstract methods and inner classes to other visitors.
	 * 
	 * NB - Like other visitors in this structure, this class relies on a context object to give
	 * most of it's functions any useful meaning - this is an inherent property of the AST tree
	 * structure and is not a coupling problem as such.	
	 */

public class AbstractClassVisitor<A> extends VoidVisitorAdapter<A> {
	
	private VariableAndParameterLogger storage;
	private IVisitorContext parent;
	
	
	public AbstractClassVisitor(VariableAndParameterLogger logger, IVisitorContext parent) {
		
		storage = logger;
		this.parent = parent;
	}

	@Override
	public void visit (ClassOrInterfaceDeclaration n, A arg) {
		
	    // Visit VariableDeclarator - class variables of all types
        VariableVisitor<A> vVisitor = new VariableVisitor<>(storage, parent);
        n.accept(vVisitor, arg);
        
        // Visit Methods - method parameters, methods inner variables
        MethodVisitor<A> mVisitor = new MethodVisitor<>(storage, parent);
        n.accept(mVisitor, arg);
		
	}
	
}
